/*!
 * @copyright 2009-2019 Vanilla Forums Inc.
 * @license GPL-2.0-only
 */

.embedImage {
    width: 100%;
    max-width: 100%;
    display: block;

    & .embedExternal-content {
        display: block;
    }

    // For the rendered page
    &.display-inline {
        display: inline-block;
        vertical-align: middle;
        width: fit-content;

        & .embedExternal-content {
            display: inline;
        }

        // Extra specificity to override UserContent styles
        &.embedExternal.embedImage.display-inline {
            margin: 0 !important;
            font-size: inherit;
        }
    }

    .embedExternal-content {
        display: block;
    }

    @include mediaQuery-embedDesktop {
        &:after {
            // Prevents paragraphs from collapsing borders with images.
            // This way the margin for the paragraph aligns with the image.
            content: "";
            display: block;
            height: 1px;
        }

        &.display-small .embedExternal-content {
            max-width: calc(33.333% - 1px);
        }

        &.display-inline .embedExternal-content {
            width: fit-content;
            height: 1em;
        }

        &.display-medium .embedExternal-content {
            max-width: calc(66.666% - 1px);
        }

        &.display-large,
        &.display-large .embedImage-img {
            // The display sizes above handle the actual width of the image.
            width: 100%;
        }

        &.float-left .embedExternal-content {
            float: left;
            margin-right: 20px;
        }

        &.float-right .embedExternal-content {
            float: right;
            margin-left: 20px;
        }
    }
}

.Message img .embedImage-img, // Compatibility
.embedImage-img {
    height: auto;
    display: inline-flex; // https://github.com/vanilla/support/issues/3336
    position: relative;
    margin: {
        left: auto;
        right: auto;
    }
    max-width: 100%;
    max-height: $embed_image_max_height;
}

.bbcode_left {
    .embedImage-img {
        margin-left: 0;
        display: inline-block;
    }
}
.bbcode_right {
    .embedImage-img {
        margin-right: 0;
        display: inline-block;
    }
}
.embedImage-link {
    display: flex; // https://github.com/vanilla/support/issues/3336
    flex-direction: column;
}

.display-inline .embedImage-link {
    height: auto;
}

.display-inline .embedImage-img {
    height: 1em;
    width: auto;
}
